package com.tong.dao;

import com.tong.pojo.Books;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import java.util.List;

public interface BookMapper {
   //增加一个Book
   @Insert("insert into ssmbuild.books(bookName,bookCounts,detail) values (#{bookName}, #{bookCounts}, #{detail})")
   int addBook(Books book);

   //根据id删除一个Book
   @Delete("delete from ssmbuild.books where bookID=#{bookID}")
   int deleteBookById(int id);

   //更新Book
   @Update("update ssmbuild.books set bookName = #{bookName},bookCounts = #{bookCounts},detail = #{detail} where bookID = #{bookID}")
   int updateBook(Books books);

   //根据id查询,返回一个Book
   @Select("select * from ssmbuild.books where bookID = #{bookID}")
   Books queryBookById(int id);

   //查询全部Book,返回list集合
   @Select("SELECT * from ssmbuild.books")
   List<Books> queryAllBook();

}